package com.wx.nchu_mall.web;

import com.wx.nchu_mall.model.OrderItem;
import com.wx.nchu_mall.service.OrderItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class OrderItemController {

    @Autowired
    protected OrderItemService orderItemService;

    @PostMapping("/api/orderitem/{orderId}")    //通过订单ID来查询子订单信息表
    public List<OrderItem> findOrderList (@PathVariable Integer orderId ){
        return orderItemService.findOrderList(orderId);
    }
    @PostMapping("/api/orderitem/getOrderitem")
    public List<OrderItem> findOrderitem(@RequestBody OrderItem orderItem){
        return orderItemService.findOrderitem(orderItem);   //查询订单列表
    }
    @PostMapping("/api/orderitem/addOrderitem")
    public String addOrderitem(@RequestBody OrderItem orderItem){
        orderItemService.insert(orderItem);
        return "success";
    }
}
